6.2.8 - SUI Textbox


What is a Textbox?

It's a box field where you can type. In SUI it's defined as STextbox.

We can add it to a panel or container as usual:


var panel = RegisterNewPanel("panel id", true).Anchor(AnchorType.MiddleCenter).Background(Color.blue, EBackground.RoundedStandard).Size(1280, 720);
var container = SContainer.Background(Color.green).Anchor(AnchorType.Fill)
                    - STextbox.Text("Label"); // adding a textbox to the container

panel.Add(container);
            
Textbox in container

We can also use .Notify to call a method which will receive the content of the textbox as a string argument whenever the content of it changes:


public static void Create()
{
    var panel = RegisterNewPanel("panel id", true).Anchor(AnchorType.MiddleCenter).Background(Color.blue, EBackground.RoundedStandard).Size(1280, 720);
    var container = SContainer.Background(Color.green).Anchor(AnchorType.Fill)
                        - STextbox.Text("Label").Notify(ReceiveText); // calling "ReceiveText" whenever a change is made in the textbox

    panel.Add(container);
}

private static void ReceiveText(string text)
{
    RLog.Msg(text);
}
            
Textbox with notify